home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Textfiles / zines / Midnight-Raid / midnight raid 8_app_640x480.sit / tmr 8 small.rsrc / TEXT_2700_16 Hex and Such....txt < prev    next >
Text File  |  2000-01-09  |  20KB  |  338 lines

  1. (hex and such by proZaq continued)
  2.  
  3. --==< The Computer's Hardware Components >==--
  4.  
  5. Now we have covered a lot of track.  You should know what the different number systems are,
  6. you should have an understanding of different programing expressions and you should know
  7. how to use a HexEditor.  In order to understand how a Debugger works, however, we need to
  8. dive into the hardware components of a computer.  Do not worry, I will keep it simple.  I
  9. will only talk about the most important parts of the computer.  As a matter of fact you
  10. will most likely recognize and already know the function of some of these components.
  11.  
  12. - The Motherboard - This is that green board within your computer covered with circuits
  13. where all the hardware is placed.  Everything from the diskdrive to the microphone is
  14. somehow connected to the Motherboard.
  15. - Memory - The part of the computer where data is stored.
  16. - RAM (Random Access Memory) - This is the temporary storage facility of the computer.
  17. It is loaded full with information when you turn on the computer and it is emptied when
  18. you turn your computer off.  
  19. - PRAM (Parameter RAM) - Very much like ordinary RAM with the exception that there is a
  20. special battery in the computer providing the PRAM with enough electricity to keep the
  21. information in it even when the rest of the computer is turned off.  
  22. - ROM (Read Only Memory) - This is a storage unit where information can only be read from. 
  23. With other words the computer can read anything in the ROM but it can not change anything
  24. there.  Thus the ROM usually stores all the information the computer needs to be able to
  25. start when you press the "On" button.  When you think about it, a compact disk (CD) is
  26. also a read-only unit.  The computer can read the information on it, but it can't store 
  27. stuff on it. Thus the name CD-ROM.
  28. - Storage Media - For example, the HardDrive, a floppy disk, a Zip disk, etc.  These
  29. are accessories to the computer on which information is stored "indefinitely".  That is
  30. "indefinitely" in the sense that the information will still be there, even when the
  31. computer off.  This does, however, not keep the computer from replacing the information on
  32. the media. So it can freely read from it and write to it.  It can even replace existing
  33. data with new data.
  34. - The Processor - This is the brain of the computer.  All data is sent to be calculated in
  35. the processor.  
  36. - Registers - These are blocks of memory within the processor where data is stored for a
  37. brief period of time, waiting to be processed.
  38. - Busses - Circuits, on the motherboard, where the information travels from one component
  39. of the motherboard to the other.
  40. - The Sound Card - This is like a small mother board with it's own processor, busses and
  41. registers capable of converting binary information to sound waves.
  42. - The Graphics Card - Same as the sound card except it displays information as the
  43. graphics on the monitor.
  44.  
  45. And that's all you need to know for now.
  46.  
  47.  
  48. --==< Debuggers >==--
  49.  
  50. I gave this whole chapter a lot of thought and decided on the following.  I will only give a
  51. general description of a debugger, and some theoretical uses for it.  There are a lot of
  52. different debuggers out there, for all computer platforms.  I use a Macalong with Apple's
  53. own free debugger called MacsBug.  For those interested I have included a file called
  54. "MacsBug".  I wrote this file a while back and it is not designed to be read by beginners. 
  55. However, some people might find it handy.  There are a quite a lot of other files dealing
  56. with MacsBug that might be a lot more useful.  So if you are really interested, read a few
  57. of those as well!  
  58.  
  59. A debugger is a program that allows you to take control of the complete computer.  This is
  60. done, by "stoping" the processor.  When you activate a debugger, it stops the processor
  61. from executing any commands of the program that is running at the moment.  The whole
  62. concept of a debugger is to help software developers look for mistakes in their programs or
  63. to see if it executes in a proper way.   
  64.  
  65. As you may know, when a program is launched, the Operating System loads the program from
  66. the HardDrive to the RAM.  This is done because the RAM is a lot faster than the HardDrive
  67. and most other storage medias.  Then the processor jumps to the part of the RAM where the
  68. code of the program is stored, and it starts executing each of the commands.  So, when the
  69. debugger is started the processor stops executing these commands.  It then allows the user
  70. to check the values of the certain hardware components.  This way the user can detect any
  71. mistakes in the program or just check the current state of the hardware components.  The
  72. user can even step through the code of the program.  This means that they can look at each
  73. command that makes up the program and see what it does.  As I said before, debuggers are
  74. largely used by programmers trying to figure out why their program won't work properly.
  75.  
  76. For you, the main advantage of a debugger will be that it allows you to change the data in
  77. most hardware components, including the RAM.  Since the program is loaded into the RAM when
  78. launched, and it does all the calculations in the RAM all the data/variables/information it
  79. may use will most likely be stored somewhere in the RAM.  Thus the debugger can be used to
  80. change any of these.
  81.  
  82. Since this file has had a general undertone of being an aid for cheating on computer games
  83. I decided to include a way to use MacsBug to cheat on games while you are actually playing
  84. them. I will first summarize the theory and then go into the specifics.  In order for you
  85. to be able to follow it through you will have to know at least the basic commands and
  86. functions of MacsBug.  If you are using a different debugger, then the theory will most
  87. likely be the same but the commands will be different.
  88.  
  89. WARNING:  When you are changing memory contents or changing anything in a debugger for
  90. that matter, you CAN cause very large damages to your computer!  The incorrect use of a
  91. debugger can cause the computer to freeze and cause information to be lost!  Several other damages
  92. can also occur.  Thus I advise you to become familiar with your debugger before you
  93. attempt to change anything with it.  Read any related files, read the manuals and do some
  94. minor experimenting before you try to change stuff directly in the memory! 
  95.  
  96. So first, the theory.  I launch the game as a start.  By opening up any saved games, I
  97. force the game to load anything it might have saved on the HardDrive (and that is of use
  98. to me) to the RAM.  Then I stop the game by starting the debugger, I find where in the
  99. RAM the game is stored, I find the information I want to change and then I change it.
  100.  
  101. OK, and now for practice:
  102.  
  103. Here's the scenario:  I'm playing Heroes of Might & Magic II and I want more creatures in
  104. my armies.  I open up the hero's preference window and see that my hero has 25 Minotaurs,
  105. 53 Dwarfs, 32 Griffins, 9 Skeletons and 2 Dragons.  Thus I know that the computer keeps
  106. track of how many creatures I have and that means that the number of creatures must be
  107. stored somewhere in the RAM.   
  108.  
  109. The first thing I have to do is to find out where in the RAM the game is located.  The
  110. first step is to drop into MB (this is done by holding down the apple key and pressing 
  111. the power button on the keyboard).  
  112.  
  113. The second step is to issue the "hz" (heap zone) command that lists all the currently
  114. active applications and their locations in the RAM.  I got this:
  115.  
  116.  Heap zones
  117.   #1  Mod        7206K  00002800 to 0070C34F  SysZone^
  118.   #2  Mod           6K    00008D60 to 0000A88F  ROM read-only zone
  119.   #3  Mod          48K    001301F0 to 0013C1EF
  120.   #4  Mod         128K    004475B0 to 004675AF
  121.   #5  Mod       29560K  0070C350 to 023EA69F  Process Manager zone
  122.   #6  Mod        9737K    010A6830 to 01A28EFF  ‚ÄúHeroes II‚Äù     ApplZone^  TheZone^  Targ
  123.  
  124. As you can see Heroes II starts at memory location 010A6830 and ends at 01A28EFF (all in
  125. hex of course).  
  126.  
  127. The next step is to use the "find" command and find the number of creatures that make up
  128. my army.  See, it is very likely that a game stores relevant data close to each other. So
  129. I presume that the program stores the number of creatures I have, in a specific block of
  130. memory in the RAM.  If I can find this block of memory, I will be able to change it's
  131. content, thus changing the number of creatures.   In some ways it's like finding
  132. information with a HexEditor.  Except you're looking for data in the RAM and not in a
  133. file.
  134.   
  135. In order to be able to use the "find" command I have to be able tell the following things:
  136. the start of the memory address, how many bytes the debuggers should search for, and what
  137. to search for.  Unfortunately I don't have all the criteria.  I have to find out how many
  138. bytes Heroes II occupies.  This can easily be done by subtracting $010A6830 from
  139. $01A28EFF. This subtraction gives me $009826CF.  If you want you can do this calculation
  140. directly in MB, just type "01A28EFF-009826CF".  Now I have all the stuff I need to use
  141. the find command.  
  142.  
  143. In this example I issue "f 010A6830 009826CF 00190035"
  144.  
  145. The "f" stands for "find". This tells MB to use the find command.  
  146. "010A6830" is the address of the memory where Heroes II starts.  
  147. "009826CF" stands for the number bytes Heroes II occupies in the memory. It tells MB the
  148. number of bytes I want to search for, from the initial address.  
  149. "00190035" stands for 25 Minotaurs and 53 Dwarfs.  #25=$19 and #53=$35.  Since I've done
  150. this before I know that Heroes II stores the the number of creatures in word sized blocks
  151. of memory.  If I didn't know that I would have had to search for "0019" first (or "19")
  152. and look at it in it's context.  When I issued the find command I got this:
  153.  
  154. Searching for 00190035 from 010A6830 to 01A28EFE
  155.   0118EE3E  0019 0035 0020 0009  0002 0000 0003 0100  ‚Ä¢‚Ä¢‚Ä¢5‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢
  156.  
  157. The first hex long represents an address in the memory.  The following four longs (16
  158. bytes) are the values of the data contained in the RAM starting from that address.  The
  159. following 16 characters are the ASCII representations of these values.
  160.  
  161. Now, if I convert the first five words to decimal numbers I get: 25, 53, 32, 9 and 2.
  162. That's a perfect match of the number of creature I have in my army.  Thus there is a
  163. fairly good chance that HeroesII keeps track of my army starting at address 0118EE3E.
  164. When you are doing something like this on your own and you don't think that this is the
  165. location of the memory that you are looking for, you can continue searching by hitting
  166. return until you get a message saying that it could not be found.
  167.  
  168. Then comes the dangerous part, I have to change the value in the memory.  I issue the
  169. following command, "sw 0118EE3E 00ff" (sw stands for set word).  This changed the word at
  170. the memory address 0118EE3E from "0019" to "00ff".  If I now issue the "dm 0118EE3E"
  171. command (dm stands for display memory) I see that the value at address 0118EE3E has
  172. changed to:
  173.  
  174.   0118EE3E  00FF 0035 0020 0009  0002 0000 0003 0100  ‚Ä¢‚Ä¢‚Ä¢5‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢
  175.  
  176. So I return to the game by issuing the "g" command.  Apparently nothing has changed.  But
  177. if I close the preferences window and force the game to actually check how many Minotaurs
  178. my army has (by checking the variable stored in the RAM), then I can see that the game in
  179. fact thinks that I have 255 Minotaurs!  Cheat accomplished.  Now I just have to repeat the
  180. above procedures for all the other creatures.
  181.  
  182. NOTE: when you are changing the contents of the memory, make sure that you use the
  183. appropriate addresses, meaning the ones you get when you issue "hz" and the find command.
  184. Do NOT use the memory addresses I used!  They are purely examples and WILL NOT work on
  185. your computer!
  186.  
  187.  
  188.  
  189. --==< End Notes >==--
  190.  
  191. In conclusion I hope to have given an insight to how different principles of computer
  192. technology work.  I'd like to point out to some more advanced readers that I am aware of
  193. the fact that I have generalized and simplified some concepts.  I did this only when I
  194. felt that the theory was more important than a detailed explanation.  I also hope to have
  195. made some of you interested in learning about programing and more advanced topics of IT
  196. and computer technology.  If you have any questions or comments you can reach me at
  197. prozaq@usa.net.
  198.  
  199. Good luck
  200.  
  201. ProZaq
  202. 1999.12.31 
  203.  
  204. Werd to mSEC, and everyone else who's ever helped me out!  It's people like you who make
  205. it worthwhile!
  206.  
  207.  
  208.  
  209.  
  210.  
  211. The most common ASCII characters (to be viewd in Monaco)
  212.  
  213.  32 ' '  $20     33 '!'  $21     34 '"'  $22     35 '#'  $23     36 '$'  $24
  214.  37 '%'  $25     38 '&'  $26     39 '''  $27     40 '('  $28     41 ')'  $29
  215.  42 '*'  $2A     43 '+'  $2B     44 ','  $2C     45 '-'  $2D     46 '.'  $2E
  216.  47 '/'  $2F     48 '0'  $30     49 '1'  $31     50 '2'  $32     51 '3'  $33
  217.  52 '4'  $34     53 '5'  $35     54 '6'  $36     55 '7'  $37     56 '8'  $38
  218.  57 '9'  $39     58 ':'  $3A     59 ';'  $3B     60 '<'  $3C     61 '='  $3D
  219.  62 '>'  $3E     63 '?'  $3F     64 '@'  $40     65 'A'  $41     66 'B'  $42
  220.  67 'C'  $43     68 'D'  $44     69 'E'  $45     70 'F'  $46     71 'G'  $47
  221.  72 'H'  $48     73 'I'  $49     74 'J'  $4A     75 'K'  $4B     76 'L'  $4C
  222.  77 'M'  $4D     78 'N'  $4E     79 'O'  $4F     80 'P'  $50     81 'Q'  $51
  223.  82 'R'  $52     83 'S'  $53     84 'T'  $54     85 'U'  $55     86 'V'  $56
  224.  87 'W'  $57     88 'X'  $58     89 'Y'  $59     90 'Z'  $5A     91 '['  $5B
  225.  92 '\'  $5C     93 ']'  $5D     94 '^'  $5E     95 '_'  $5F     96 '`'  $60
  226.  97 'a'  $61     98 'b'  $62     99 'c'  $63    100 'd'  $64    101 'e'  $65
  227. 102 'f'  $66    103 'g'  $67    104 'h'  $68    105 'i'  $69    106 'j'  $6A
  228. 107 'k'  $6B    108 'l'  $6C    109 'm'  $6D    110 'n'  $6E    111 'o'  $6F
  229. 112 'p'  $70    113 'q'  $71    114 'r'  $72    115 's'  $73    116 't'  $74
  230. 117 'u'  $75    118 'v'  $76    119 'w'  $77    120 'x'  $78    121 'y'  $79
  231. 122 'z'  $7A    123 '{'  $7B    124 '|'  $7C    125 '}'  $7D    126 '~'  $7E
  232. 127 ''   $7F    128 '√Ñ'  $80    129 '√Ö'  $81    130 '√á'  $82    131 '√â'  $83
  233. 132 '√ë'  $84    133 '√ñ'  $85    134 '√ú'  $86    135 '√°'  $87    136 '√†'  $88
  234. 137 '√¢'  $89    138 '√§'  $8A    139 '√£'  $8B    140 '√•'  $8C    141 '√ß'  $8D
  235. 142 '√©'  $8E    143 '√®'  $8F    144 '√™'  $90    145 '√´'  $91    146 '√≠'  $92
  236. 147 '√¨'  $93    148 '√Æ'  $94    149 '√Ø'  $95    150 '√±'  $96    151 '√≥'  $97
  237. 152 '√≤'  $98    153 '√¥'  $99    154 '√∂'  $9A    155 '√µ'  $9B    156 '√∫'  $9C
  238. 157 '√π'  $9D    158 '√ª'  $9E    159 '√º'  $9F    160 '‚Ć'  $A0    161 '¬∞'  $A1
  239. 162 '¬¢'  $A2    163 '¬£'  $A3    164 '¬ß'  $A4    165 '‚Ä¢'  $A5    166 '¬∂'  $A6
  240. 167 '√ü'  $A7    168 '¬Æ'  $A8    169 '¬©'  $A9    170 '‚Ñ¢'  $AA    171 '¬¥'  $AB
  241. 172 '¬®'  $AC    173 '‚â†'  $AD    174 '√Ü'  $AE    175 '√ò'  $AF    176 '‚àû'  $B0
  242. 177 '¬±'  $B1    178 '‚â§'  $B2    179 '‚â•'  $B3    180 '¬•'  $B4    181 '¬µ'  $B5
  243. 182 '‚àÇ'  $B6    183 '‚àë'  $B7    184 '‚àè'  $B8    185 'œÄ'  $B9    186 '‚à´'  $BA
  244. 187 '¬™'  $BB    188 '¬∫'  $BC    189 'Œ©'  $BD    190 '√¶'  $BE    191 '√∏'  $BF
  245. 192 '¬ø'  $C0    193 '¬°'  $C1    194 '¬¨'  $C2    195 '‚àö'  $C3    196 'Δí'  $C4
  246. 197 '‚âà'  $C5    198 '‚àÜ'  $C6    199 '¬´'  $C7    200 '¬ª'  $C8    201 '‚Ķ'  $C9
  247. 202 '¬†'  $CA    203 '√Ä'  $CB    204 '√É'  $CC    205 '√ï'  $CD    206 '≈í'  $CE
  248. 207 '≈ì'  $CF    208 '‚Äì'  $D0    209 '‚Äî'  $D1    210 '‚Äú'  $D2    211 '‚Äù'  $D3
  249. 212 '‚Äò'  $D4    213 '‚Äô'  $D5    214 '√∑'  $D6    215 '‚óä'  $D7    216 '√ø'  $D8
  250. 217 '≈∏'  $D9
  251.  
  252.  
  253.  
  254.  
  255. This is no complete manual to MacsBug.  This is taken from a file I wrote a while
  256. back and is meant to be an extension of the file called "Hex and Such".
  257.  
  258.  
  259. --==< The Basics >==--
  260.  
  261.  
  262. You install MacsBug simply by throwing it into the System Folder, and by restarting
  263. your machine.  You activate it by pressing the ‚Äúcommand‚Äù and ‚Äúpower-key‚Äù (the one
  264. towards the top of your keyboard marked with the head of an arrow pointing to the
  265. left) buttons.  This should have ‚Äúdropped‚Äù you into MacsBug.  You will notice that
  266. you are in MacsBug because your desktop is replaced with a with a bunch of numbers on
  267. a white background.  
  268. Well, going from the top left side, under ‚ÄúSP‚Äù is the current position of the stack
  269. pointer, underneath the position of the SP are the values contained in the SP.  
  270. Under those numbers is the name of the application that is currently the foremost
  271. one.  
  272. Under that is the status of the Status Register, followed by the info held in the 8
  273. data registers, and the 8 address registers (or the 32 registers if it is a PPC
  274. program).  To the right of the registers is a horizontal line going across the
  275. screen.  
  276. Under that are about 4 lines of text.  The topmost line describes where in the
  277. application‚Äôs code the processor was halted.  Under that line are 3 other lines with
  278. assembly commands.  These are the three commands in line to be executed.  
  279. To the right of them (in the right bottom corner) are the hexadecimal values of the
  280. assembly commands.  
  281. Above this section (in the middle) is a large empty space.   This gets filled up with
  282. the results of the commands you give to MacsBug.  
  283. Your commands get written under the three assembly commands.  
  284.  
  285. What happens when you drop into MacsBug is that your processor stops executing
  286. commands, and you can for example go through a code step by step, command by command,
  287. following through exactly what the program does.  So how do you do that?
  288. Type ‚Äút‚Äù followed by a return.
  289. This causes the processor to execute the next assembly command in line.  The assembly
  290. command that was executed appears now in the middle blank section of your screen, and
  291. a new assembly command appears under the two old ones.
  292.  
  293.  
  294. --==< Basic MacsBug Commands >==--
  295.  
  296.    - t : traces over the next command in line.  If it is used on a JSR command it
  297. jumps over the the subroutine.  (It executes the whole subroutine, without allowing
  298. you to see what happened)
  299.  
  300.    - s : does the same thing as ‚Äút‚Äù except it ‚Äústeps into‚Äù a subroutine.  For example
  301. if you are not interested in what happens in an subroutine you should type ‚Äút‚Äù.  This
  302. causes the processor to continue until it reaches a RTS command, and only then give
  303. the control back to you.  If you on the other hand want to see what happens in that
  304. subroutine, you should type ‚Äús‚Äù to step into it and follow through the code from
  305. there.
  306.  
  307.    - es : this forces the current application to quit (not always).  
  308.    
  309.    - rs :  restarts your computer (sometimes it doesn't work and you have to do it
  310. the old fashioned way: apple-control-powerkey)
  311.  
  312.    - rb :  reboots your computer (boots up the different external devices at
  313. startup).  This is slower then the ‚Äúrb‚Äù command
  314.  
  315.    - dm [address] : displays what is in the memory at a given address.  For example,
  316. the command ‚Äúdm a6‚Äù shows you what is held in the address pointed to by address
  317. register 6.  If you type ‚Äúdm abcd‚Äù  it shows you what is held in the memory at
  318. location ‚Äúabcd‚Äù (in hex that is).
  319.  
  320.    - db [address] : displays byte from address
  321.  
  322.    - dw [address] : displays word from address
  323.  
  324.    - dl [address] : displays long from address
  325.  
  326.    - il : dissembles the codes.  Used if you, for example, want to see what happens
  327. after a branch code.
  328.  
  329.    - atb [a-trap name] : MacsBug activates every time that a-trap is being called.
  330.  
  331.    - atc : clears a-traps
  332.  
  333.    - f address expr ‚Äòstring‚Äô : this is the find command.  ‚Äúaddress‚Äù refers to the
  334. starting point of the search; ‚Äúexpr‚Äù is how many bytes it should search; ‚Äú ‚Äôstring' ‚Äù
  335. is what you‚Äôre looking for!  Observe the semi quotation mark before the string!  You
  336. need to use that!
  337.  
  338. You can find out more about commands for MacsBug by typing ‚Äúhelp‚Äù